﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;


namespace Web.Account
{
    public enum enmGroup
    {
        group1,
        group2,
    }
    public partial class Login : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            RegisterHyperLink.NavigateUrl = "Register.aspx";
            OpenAuthLogin.ReturnUrl = Request.QueryString["ReturnUrl"];

            var returnUrl = HttpUtility.UrlEncode(Request.QueryString["ReturnUrl"]);
            if (!String.IsNullOrEmpty(returnUrl))
            {
                RegisterHyperLink.NavigateUrl += "?ReturnUrl=" + returnUrl;
            }
        }

        protected void Unnamed1_Authenticate(object sender, AuthenticateEventArgs e)
        {
            if (FormsAuthentication.CookiesSupported) { }

            bool p = mylogin.RememberMeSet;
            string name = mylogin.UserName;
            string pwd = mylogin.Password;

            e.Authenticated = Membership.ValidateUser(name, pwd);//提供程序未返回 ProviderManifestToken 字符串

            if (e.Authenticated)
            {
                if (name == "zuchunming")
                {
                    // Response.Redirect("~/admin.aspx");
                    FormsAuthentication.RedirectFromLoginPage(name, p);
                }
                else
                {
                    // Response.Redirect("~/Default.aspx");
                    FormsAuthentication.RedirectFromLoginPage(name, p);
                }
            }
        }
    }
}